<!DOCTYPE html>
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="format-detection" content="email=no"/>
    <meta charset="UTF-8">
    <script type="text/javascript" th:src="@{${session.baseUrl}+'js/common.js'}"></script>
    <script th:src="@{${session.baseUrl}+'js/jquery.js'}"></script>
    <link th:href="@{${session.baseUrl}+'style/reset.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/base.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/header.css'}" rel="stylesheet" type="text/css">
    <link rel="stylesheet" th:href="@{${session.baseUrl}+'style/pay.css'}"/>
    <link th:href="@{${session.baseUrl}+'style/dialog.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/global.css'}" rel="stylesheet" type="text/css">
    <script th:src="@{${session.baseUrl}+'js/dialog.js'}"></script>
    <title>支付页面</title>
</head>
<body>
<header><span onclick="javascript:history.go(-1)"></span>支付</header>
<input id="projectId" type="hidden" th:value="${drafts.id}">
<input id="couid" type="hidden" th:value="${coupon.id}">
<div class="mt20 f26 bgwh df pr30 pl30 jcsb all"><span>需要支付</span><span class="g6" th:text="'￥'+${money}"></span></div>
<span th:if="${#lists.isEmpty(CouponList)}">
    <div class="mt20 f26 bgwh df pr30 pl30 jcsb all"><span>优惠券</span><span class="useOr">无优惠券可用</span></div>
</span>
<span th:unless="${#lists.isEmpty(CouponList)}">
    <a style="text-decoration:none; color:#323232;" th:href="@{/wap/memberProject/toxuan/(projectId=${drafts.id},money=${money},orderId=${orderId})}">
        <div class="mt20 f26 bgwh df pr30 pl30 jcsb all">
            <span>优惠券</span>
                <span th:if="${coupon.rate!=0.00}">
                    <span class="useOr1" th:text="'+'+${#numbers.formatDecimal(100*coupon.rate,1,2)}+'%'"></span>
                </span>
                <span th:if="${coupon.rate==0.00}">
                    <span class="useOr1" >去选择</span>
                </span>
        </div>
    </a>
</span>

<!--<ul class="mt20 bgwh">
    &lt;!&ndash;<li class=" f26 bgwh df pr30 pl30 jcsb all bte"><label for="money" class="f26">还需支付</label><input type="text" id="money" name="money" disabled value="¥19.00"/></li>
    <li class=" f26 bgwh df pr30 pl30 jcsb all bte aic"><label for="qb" class="f26">钱包支付</label><input type="radio" name="method" id="qb"/></li>
    <li class=" f26 bgwh df pr30 pl30 jcsb all bte aic"><label for="wx" class="f26">微信支付</label><input type="radio" name="method" id="wx"/></li>&ndash;&gt;
</ul>-->
<input type="submit" value="余额支付" onclick="pay()"/>
<!--<input type="submit" value="微信支付"/>-->


<script type="text/javascript" th:inline="javascript">

    var basePath = /*[[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]]*/;

    /***支付*/
    function pay() {

        setTimeout(function(){$.ajax({
            url: "/memberProject/add2",
            contentType: 'application/json',
            type: "POST",
            dataType: "json",
            data: JSON.stringify({
                money: [[${money}]],
                memberId: [[${session.memberId}]],
                projectId: $('#projectId').val(),
                rate: [[${drafts.rate}]],
                infoI: 0,
                status: 1,
                orderId: [[${orderId}]],
                couponId:$('#couid').val(),
            }),
            success: function (e) {
                if (e.data) {
                    $('body').dailog({type: 'success', title: '购买', discription: '购买成功'});
                    self.setInterval(function () {
                        window.location.href = basePath + "/wap/index.html";
                    }, 3000) //这里3000代表3秒
                } else {
                    $('body').dailog({type: 'warning', title: '购买', discription: '订单已支付'});
                    self.setInterval(function () {
                        location.reload();
                    }, 3000)
                }

            }
        })},3000)
    }


</script>
</body>
</html>
